<template>
  <!--<p>{{name}} - {{age}} - {{stateAge}}</p>
  <button @click="changeAge(17)">点击修改年纪</button>
  <button @click="getCart">获取购物车数据</button>
  <ul>
    <li v-for="(item, i) in products" :key="i">{{item.name}}</li>
  </ul>-->
  <div @click="$router.push('/about')">about</div>
</template>

<script>
// import { useStore } from 'vuex'
import { computed } from 'vue'
import store from '@/utils/store'
export default {
  name: 'Home',
  // vuex的使用
  // setup() {
  //   let store = useStore()
  //   // console.log(store);
  //   let name = computed(() => store.state.name)
  //   // let age = store.state.age
  //   return {
  //     name,
  //     stateAge: computed(() => store.state.age),
  //     age: computed(() => store.getters.fomateAge),
  //     products: computed(() => store.state.products),
  //     changeAge: (num) => store.commit('changeAge', num),
  //     getCart: () => store.dispatch('getProducts')
  //   }
  // }
  setup() {
    let name = '张三'
    store.changeName(name)
    console.log(store);
  }
}
</script>
